import { request } from "@/utils/request";
import type {
  DeleteParams,
  FunctionParams,
  QueryByIdParams,
  QueryByIdResult,
  QueryParams,
  QueryResult,
} from "./typing";
import type { PageResult, ResponseBody } from "@/api/typing";

/**分页查询功能 */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/low-code/function/page",
    { params }
  );
};

/**新增功能 */
export const add = (params: FunctionParams) => {
  return request.post<FunctionParams, ResponseBody>(
    "/low-code/function/add",
    params
  );
};

/**修改功能 */
export const update = (params: FunctionParams) => {
  return request.put<FunctionParams, ResponseBody>(
    "/low-code/function/update",
    params
  );
};

/**删除功能 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>(
    "/low-code/function/delete",
    { params }
  );
};

/**查询单个功能 */
export const queryById = (params: QueryByIdParams) => {
  return request.get<QueryByIdParams, ResponseBody<QueryByIdResult>>(
    "/low-code/function/id",
    { params }
  );
};
